class Solution(object):
    def addSpaces(self, s, spaces):
        ans = []
        for index, num in enumerate(spaces):
            if index == 0:
                if num != 0:
                    ans.append(s[:num])
                ans.append(' ')
            else:
                ans.append(s[spaces[index - 1]: num])
                ans.append(' ')
        ans.append(s[spaces[-1]:])
        return ''.join(ans)

